package org.tmsps.ne4spring.base;

import org.tmsps.ne4spring.base.ne.NePage;
import org.tmsps.ne4spring.orm.model.DataModel;
import org.tmsps.ne4spring.orm.param.NeParamList;

import java.util.List;
import java.util.Map;

/**
 * 
 *======================================================
 * @author zhangwei 396033084@qq.com 
 *------------------------------------------------------
 * IBaseService base service interface
 *======================================================
 */
public interface IBaseService extends BaseQueryService {
	
	//与数据库表的信息对应,保存进入数据库,sync 为是否需要同步一次Model,用于数据库中默认属性的回填
	public int saveObj(DataModel model);
	public int saveObj(DataModel model, boolean sync);
	public void saveObjs(List<? extends DataModel> objs);

	public int deleteById(Object id, Class<? extends DataModel> clazz);
	public int deleteRealById(Object id, Class<? extends DataModel> clazz);
	
	public int updateObj(DataModel obj);
	
	public <T extends DataModel> T findById(Object idVal, final Class<? extends DataModel> clazz);
	
	public Map<String, Object> findMap(String sql, Object... vals);
	public <T extends DataModel> T  findObj(Class<T> clazz, String sql, Object... vals) ;

	public List<Map<String, Object>> findList(String sql, Object... vals);
	public <T> List<T> findList(Class<T> clazz, String sql, Object... vals);

	public <T> List<T> findList(Class<T> clazz, NePage page, String sql, Map<String, String> sort_params, Object... vals);
	public <T> List<T> findList(Class<T> clazz, NePage page, String sql, Object... vals);
	
	public List<Map<String, Object>> findList(String sql, NeParamList params);
	public <T> List<T> findList(Class<T> clazz, String sql, NeParamList params);

}
